package com.zhitxx.common.utils

import android.util.Log
import java.lang.Exception

fun String2Int(value: String): Int {
    if (value.isNotEmpty()) {
        try {
            return value.toInt()
        } catch (ex: Exception) {
            ex.printStackTrace()
        }
    }
    return 0
}

fun String2Long(value: String): Long {
    if (value.isNotEmpty()) {
        try {
            return value.toLong()
        } catch (ex: Exception) {
            ex.printStackTrace()
        }
    }
    return 0
}

fun String2Float(value: String): Float {
    if (value.isNotEmpty()) {
        try {
            return value.toFloat()
        } catch (ex: Exception) {
            ex.printStackTrace()
        }
    }
    return 0f
}

fun String2Double(value: String): Double {
    if (value.isNotEmpty()) {
        try {
            return value.toDouble()
        } catch (ex: Exception) {
            ex.printStackTrace()
        }
    }
    return 0.0
}
